<%@ page import="com.bw.entity.Status" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" href="resource/css/bootstrap.css">
    <script src="resource/js/jquery-3.2.1.js"></script>
    <script src="resource/js/bootstrap.js"></script>
    <script type="text/javascript" src="/resource/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
    <form method="post">
         <table class="table">
             <tr>
                 <td>收货单号:
                    <input type="text" name="shouhuoid">
                 </td>
                 <td>收货单号:
                     <input type="date" name="dtime">
                 </td>
             </tr>
             <tr>
                 <td>
                     制单人:<span id="sp1">
                        <select name="uid"><option value=''>请选择</option></select>
                     </span>
                 </td>
                 <td>
                     状态:
                     <select name="status">
                         <option value="">请选择</option>
                         <c:forEach items="<%=Status.values()%>" var="e">
                            <option value="${e.code}">${e.name}</option>
                         </c:forEach>
                     </select>
                     <select name="youxianji">
                         <option value="">请选择</option>
                         <option value="1">1</option>
                         <option value="2">2</option>
                         <option value="3">3</option>
                         <option value="4">4</option>
                         <option value="5">5</option>
                     </select>
                 </td>
             </tr>
             <tr>
                 <td>
                     递送条款:<input type="text" name="disongtiaokuan">
                 </td>
                 <td>
                     制单时间:<input type="date" name="zhidantime">
                 </td>
             </tr>
             <tr>
                 <td>
                     总重量:<input type="text" name="kg">
                 </td>
                 <td>
                     客户发货单列表:
                     <input type="text" name="kehufadan">
                 </td>
             </tr>
             <tr>
                 <td>
                     收获附件:<input type="file" size="1024*1024*5" onchange="getFile(this)">
                     <input type="text" name="picurl">
                 </td>
                 <td>
                     客户:<input type="text" name="kehu">
                 </td>
             </tr>
             <tr>
                 <td colspan="2">
                     备注:<input type="text" name="beizhu">
                 </td>
             </tr>
             <tr>
                 <td colspan="2">
                     <input type="button" value="添加" onclick="add()">
                 </td>
             </tr>
         </table>
    </form>

<script>
    function add(){
        findAll("add?"+$("form").serialize())
    }
      var sta=${u.status2}
      if(sta==1){
          $.post("selectUser",function(msg){
          for(var i in msg){
               var name=msg[i].gid+"-"+msg[i].uname
               $("[name='uid']").append("<option value='"+msg[i].uid+"'>"+name+"</option>")
          }
         })
      }

      if(sta==0){

          $("#sp1").html('')
          var name=${u.gid}
          var uid=${u.uid}
          $("#sp1").append("<input type='text' value='"+name+"' readonly='readonly'>")
          $("#sp1").append("<input type='hidden' value='"+uid+"' name='uid'>")
      }
     <%--$(function(){--%>
     <%--    var gid=${u.gid};--%>
     <%--    var uname=${u.uname};--%>
     <%--    var uid=${u.uid};--%>
     <%--    var status=${u.status2};--%>
     <%--    alert(status)--%>
     <%--    if(status==1){--%>
     <%--        $.post("selectUser",function(msg){--%>
     <%--            alert(JSON.stringify(msg))--%>
     <%--            for(var i in msg){--%>
     <%--                var name=msg[i].gid+"-"+msg[i].uname--%>
     <%--                $("[name='uid']").append("<option value='"+msg[i].uid+"'>"+name+"</option>")--%>
     <%--            }--%>

     <%--        })--%>
     <%--    }--%>

     <%--    if(status==0){--%>
     <%--        alert(gid)--%>
     <%--        alert(uname)--%>
     <%--        $("#sp1").html("<input type='text' readonly='readonly' value='"+name+"'>")--%>
     <%--        $("#sp1").html("<input type='hidden' name='uid'  value='"+uid+"'>")--%>
     <%--    }--%>
     <%--})--%>
    //文件获取
    function getFile(obj){
       var formdata= new FormData();
       formdata.append("file",obj.files[0]);
       $.ajax({
           type:"post",
           data:formdata,
           url:"getFile",
           contentType:false,
           processData:false,
           success:function (msg){
               $("[name='picurl']").val(msg)
           }
       })
    }
</script>
</body>


</html>